//
//  TabBarViewController.m
//  Shop
//
//  Created by ma c on 16/8/17.
//  Copyright © 2016年 WJH. All rights reserved.
//

#import "TabBarViewController.h"
#import "TimerViewController.h"
#import "ClassViewController.h"
#import "BuyViewController.h"
#import "MyViewController.h"
#import "NavigationBarViewController.h"

@interface TabBarViewController ()

@property (nonatomic, strong) NSArray * viewControllerArray;

@end

@implementation TabBarViewController

- (NSArray *)viewControllerArray {
    
    if (!_viewControllerArray) {
        _viewControllerArray = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"TabBarViewController.plist" ofType:nil]];
    }
    return _viewControllerArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:133/255.0 green:133/255.0 blue:133/255.0 alpha:1]} forState:(UIControlStateNormal)];
    [[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:56/255.0 green:165/255.0 blue:241/255.0 alpha:1]} forState:(UIControlStateSelected)];
    
    for (NSDictionary * dict in self.viewControllerArray) {
        
        UIViewController * viewController = [[NSClassFromString(dict[@"viewController"]) alloc] init];
        viewController.tabBarItem.image = [UIImage imageNamed:dict[@"image"]];
        viewController.tabBarItem.selectedImage = [UIImage imageNamed:dict[@"selectedImage"]];
        viewController.title = dict[@"title"];
        
        NavigationBarViewController * nav = [[NavigationBarViewController alloc] initWithRootViewController:viewController];
        
        [self addChildViewController:nav];
    }
    
//    TimerViewController * timer = [[TimerViewController alloc] init];
//    UIImage * image1 = [UIImage imageNamed:@"菜单栏限时特卖按钮未选中状态"];
//    image1 = [image1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    timer.tabBarItem.image = image1;
//    timer.tabBarItem.selectedImage = [[UIImage imageNamed:@"菜单栏限时特卖按钮选中状态"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    timer.tabBarItem.title = @"限时购";
//
//    [self addChildViewController:timer];
//    
//    
//    ClassViewController * class = [[ClassViewController alloc] init];
//    class.tabBarItem.image = [[UIImage imageNamed:@"菜单栏分类按钮未选中状态"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    class.tabBarItem.selectedImage = [UIImage imageNamed:@"菜单栏分类按钮选中状态"];
//    class.tabBarItem.title = @"分类";
//    
//    [self addChildViewController:class];
//    
//    BuyViewController * buy = [[BuyViewController alloc] init];
//    buy.tabBarItem.image = [UIImage imageNamed:@"菜单栏购物车按钮未选中状态"];
//    buy.tabBarItem.selectedImage = [UIImage imageNamed:@"菜单栏购物车按钮选中状态"];
//    buy.tabBarItem.title = @"购物车";
//    
//    [self addChildViewController:buy];
//    
//    MyViewController * My = [[MyViewController alloc] init];
//    My.tabBarItem.image = [UIImage imageNamed:@"菜单栏我的按钮未选中状态"];
//    My.tabBarItem.selectedImage = [UIImage imageNamed:@"菜单栏我的按钮选中状态"];
//    My.tabBarItem.title = @"我的";
//    
//    [self addChildViewController:My];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
